-
-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restructure project #410
Restructure project #410
Conversation
If you need any help either here or in the ts part, I'm available. |
1f703d1
to
2a92a7b
Compare
Codecov Report
@@ Coverage Diff @@
## main #410 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 137 71 -66
Lines 853 575 -278
Branches 143 146 +3
==========================================
- Hits 853 575 -278
Continue to review full report at Codecov.
|
7408597
to
c8a26ee
Compare
936d4b8
to
d84291f
Compare
d84291f
to
b6e429c
Compare
@igorwessel thanks for the offer I think this PR is sorted now but will deffo take you up on the TS offer. I'll also try to go over the TS issue you raised in the next few days when I get some time 😊 |
Do we want to continue having JSDoc on the new functions? |
"moduleNameMapper": { | ||
"src/(.*)": "<rootDir>/src/$1" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we want this? seems likely to only cause confusion for most tools
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that we can import from src
in the test files as src/
and test/
are at the same level in the directory instead of having to add ../..
to all imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but is avoiding ../
worth breaking "go to definition" etc?
I don't really have a strong opinion here (nor ownership 😀) but in the same way removing the import.all
macro makes things not require specific tooling I don't think configuring the resolver of jest and eslint (and later typescript I assume) keeps the code base as approachable as possible.
(if we want something like this, we should use https://nodejs.org/api/packages.html#subpath-imports or something that has an actual spec behind it instead of ad hoc config. That said, Jest does not support it (yet)).
Again, this is your project, not mine, so feel free to structure it how you want to 🙂 Just putting my opinion out there, because what else is the internet for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this is your project, not mine, so feel free to structure it how you want to 🙂 Just putting my opinion out there, because what else is the internet for?
Love this 😆 your opinions are always welcome!
Tbh I setup all of my Typescript projects with the ability to import from src
to make it easy to do absolute imports and move stuff around. With vscode at least (when using TS) importing from src
doesn't break go to definition
, do you know if it does in other editors?
I kind of see this PR as a precursor to switching to TS so hopefully the tooling will be better then.
This all probably stems from my Java days and when I work in Scala and being able to treat directories as packages/namespaces regardless of source set 😝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been writing Rust lately, so I feel this 😀
Actually, only toContainAnyValues/predicate.ts and toBeArrayOfSize/predicate.ts had JSDoc (besides index.d.ts), so we don't need to worry about that. I just randomly happened to look at one of those two that had it. |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [jest-extended](https://togithub.com/jest-community/jest-extended) | [`1.2.1` -> `4.0.2`](https://renovatebot.com/diffs/npm/jest-extended/1.2.1/4.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/jest-extended/4.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/jest-extended/4.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/jest-extended/1.2.1/4.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/jest-extended/1.2.1/4.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>jest-community/jest-extended (jest-extended)</summary> ### [`v4.0.2`](https://togithub.com/jest-community/jest-extended/blob/HEAD/CHANGELOG.md#402) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v4.0.1...v4.0.2) ##### Patch Changes - [`1f88101`](https://togithub.com/jest-community/jest-extended/commit/1f88101): Mark 2nd param of toHaveBeenCalledBefore and toHaveBeenCalledAfter optional ### [`v4.0.1`](https://togithub.com/jest-community/jest-extended/blob/HEAD/CHANGELOG.md#401) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v4.0.0...v4.0.1) ##### Patch Changes - [`bad7056`](https://togithub.com/jest-community/jest-extended/commit/bad7056): Fix `toHaveBeenCalledExactlyOnceWith` typings - [`1609897`](https://togithub.com/jest-community/jest-extended/commit/1609897): Remove problematic Vitest types ### [`v4.0.0`](https://togithub.com/jest-community/jest-extended/blob/HEAD/CHANGELOG.md#400) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v3.2.4...v4.0.0) ##### Major Changes - [`ab20845`](https://togithub.com/jest-community/jest-extended/commit/ab20845): Rename toHaveBeenCalledOnceWith to toHaveBeenCalledExactlyOnceWith ##### Minor Changes - [`5b80ca8`](https://togithub.com/jest-community/jest-extended/commit/5b80ca8): support vitest 0.31.0 ##### Patch Changes - [`ab20845`](https://togithub.com/jest-community/jest-extended/commit/ab20845): Make CustomMatchers extend Record to fix a TypeScript error - [`ab20845`](https://togithub.com/jest-community/jest-extended/commit/ab20845): Fix toHaveBeenCalledOnceWith messages - [`ab20845`](https://togithub.com/jest-community/jest-extended/commit/ab20845): Change unknown to any in toHaveBeenCalledBefore and toHaveBeenCalledAfter ### [`v3.2.4`](https://togithub.com/jest-community/jest-extended/blob/HEAD/CHANGELOG.md#324) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v3.2.3...v3.2.4) ##### Patch Changes - [`0b07513`](https://togithub.com/jest-community/jest-extended/commit/0b07513): Support varargs in toHaveBeenCalledOnceWith ([#​557](https://togithub.com/jest-community/jest-extended/issues/557)) ### [`v3.2.3`](https://togithub.com/jest-community/jest-extended/releases/tag/v3.2.3) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v3.2.2...v3.2.3) #### What's Changed - fix(types): fix jest AsymmetricMatcher type by [@​rluvaton](https://togithub.com/rluvaton) in [https://github.com/jest-community/jest-extended/pull/551](https://togithub.com/jest-community/jest-extended/pull/551) **Full Changelog**: jest-community/jest-extended@v3.2.2...v3.2.3 ### [`v3.2.2`](https://togithub.com/jest-community/jest-extended/releases/tag/v3.2.2) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v3.2.1...v3.2.2) #### What's Changed - fix(types): add vitest support for AsymmetricMatchers by [@​rluvaton](https://togithub.com/rluvaton) in [https://github.com/jest-community/jest-extended/pull/549](https://togithub.com/jest-community/jest-extended/pull/549) #### New Contributors - [@​rluvaton](https://togithub.com/rluvaton) made their first contribution in [https://github.com/jest-community/jest-extended/pull/549](https://togithub.com/jest-community/jest-extended/pull/549) **Full Changelog**: jest-community/jest-extended@v3.2.1...v3.2.2 ### [`v3.2.1`](https://togithub.com/jest-community/jest-extended/releases/tag/v3.2.1) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v3.2.0...v3.2.1) #### What's Changed - Change return type in Expect interface to void by [@​keeganwitt](https://togithub.com/keeganwitt) in [https://github.com/jest-community/jest-extended/pull/535](https://togithub.com/jest-community/jest-extended/pull/535) - Create pass/fail error messages only if required by [@​overlookmotel](https://togithub.com/overlookmotel) in [https://github.com/jest-community/jest-extended/pull/545](https://togithub.com/jest-community/jest-extended/pull/545) #### New Contributors - [@​verdecchia](https://togithub.com/verdecchia) made their first contribution in [https://github.com/jest-community/jest-extended/pull/541](https://togithub.com/jest-community/jest-extended/pull/541) - [@​Unclemortuary](https://togithub.com/Unclemortuary) made their first contribution in [https://github.com/jest-community/jest-extended/pull/540](https://togithub.com/jest-community/jest-extended/pull/540) **Full Changelog**: jest-community/jest-extended@v3.2.0...v3.2.1 ### [`v3.2.0`](https://togithub.com/jest-community/jest-extended/releases/tag/v3.2.0) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v3.1.0...v3.2.0) #### What's Changed - Change return type in Expect interface from `Result` to `any` (closes [#​484](https://togithub.com/jest-community/jest-extended/issues/484)) by [@​keeganwitt](https://togithub.com/keeganwitt) in [https://github.com/jest-community/jest-extended/pull/492](https://togithub.com/jest-community/jest-extended/pull/492) - Fix `toHaveBeenCalledOnceWith` typing by [@​akoreh](https://togithub.com/akoreh) in [https://github.com/jest-community/jest-extended/pull/507](https://togithub.com/jest-community/jest-extended/pull/507) - Add `vitest` info to docs by [@​silverwind](https://togithub.com/silverwind) in [https://github.com/jest-community/jest-extended/pull/515](https://togithub.com/jest-community/jest-extended/pull/515) - Mark `jest` peerDependency as optional by [@​silverwind](https://togithub.com/silverwind) in [https://github.com/jest-community/jest-extended/pull/520](https://togithub.com/jest-community/jest-extended/pull/520) - `expect`: Add matcher `toBeInRange()` to validate if array elements are within the specified range by [@​mayankshukla94](https://togithub.com/mayankshukla94) in [https://github.com/jest-community/jest-extended/pull/461](https://togithub.com/jest-community/jest-extended/pull/461) - Fix `toHaveBeenCalledOnceWith` type definition (closes [#​518](https://togithub.com/jest-community/jest-extended/issues/518)) by [@​keeganwitt](https://togithub.com/keeganwitt) in [https://github.com/jest-community/jest-extended/pull/523](https://togithub.com/jest-community/jest-extended/pull/523) #### New Contributors - [@​akoreh](https://togithub.com/akoreh) made their first contribution in [https://github.com/jest-community/jest-extended/pull/507](https://togithub.com/jest-community/jest-extended/pull/507) - [@​silverwind](https://togithub.com/silverwind) made their first contribution in [https://github.com/jest-community/jest-extended/pull/515](https://togithub.com/jest-community/jest-extended/pull/515) - [@​mayankshukla94](https://togithub.com/mayankshukla94) made their first contribution in [https://github.com/jest-community/jest-extended/pull/461](https://togithub.com/jest-community/jest-extended/pull/461) **Full Changelog**: jest-community/jest-extended@v3.1.0...v3.2.0 ### [`v3.1.0`](https://togithub.com/jest-community/jest-extended/releases/tag/v3.1.0) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v3.0.2...v3.1.0) #### What's Changed - Add toHaveBeenCalledOnceWith matcher by [@​thibautsabot](https://togithub.com/thibautsabot) in [https://github.com/jest-community/jest-extended/pull/430](https://togithub.com/jest-community/jest-extended/pull/430) - docs: mention `eslint-plugin-jest-extended` in README by [@​G-Rath](https://togithub.com/G-Rath) in [https://github.com/jest-community/jest-extended/pull/493](https://togithub.com/jest-community/jest-extended/pull/493) - Update jest monorepo to v29 (major) by [@​renovate](https://togithub.com/renovate) in [https://github.com/jest-community/jest-extended/pull/495](https://togithub.com/jest-community/jest-extended/pull/495) #### New Contributors - [@​thibautsabot](https://togithub.com/thibautsabot) made their first contribution in [https://github.com/jest-community/jest-extended/pull/430](https://togithub.com/jest-community/jest-extended/pull/430) **Full Changelog**: jest-community/jest-extended@v3.0.2...v3.1.0 ### [`v3.0.2`](https://togithub.com/jest-community/jest-extended/releases/tag/v3.0.2) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v3.0.1...v3.0.2) #### What's Changed - Fix typings of `toThrowWithMessage`, support unconstructable errors by [@​GerkinDev](https://togithub.com/GerkinDev) in [https://github.com/jest-community/jest-extended/pull/475](https://togithub.com/jest-community/jest-extended/pull/475) - Fix toHaveBeenCalledBefore/toHaveBeenCalledAfter type definition by [@​aheuermann](https://togithub.com/aheuermann) in [https://github.com/jest-community/jest-extended/pull/292](https://togithub.com/jest-community/jest-extended/pull/292) - Declare matchers for use with expect.not.MATCHER ([#​385](https://togithub.com/jest-community/jest-extended/issues/385)) by [@​dharkness](https://togithub.com/dharkness) in [https://github.com/jest-community/jest-extended/pull/386](https://togithub.com/jest-community/jest-extended/pull/386) - Change any to unknown by [@​keeganwitt](https://togithub.com/keeganwitt) in [https://github.com/jest-community/jest-extended/pull/477](https://togithub.com/jest-community/jest-extended/pull/477) #### New Contributors - [@​aheuermann](https://togithub.com/aheuermann) made their first contribution in [https://github.com/jest-community/jest-extended/pull/292](https://togithub.com/jest-community/jest-extended/pull/292) **Full Changelog**: jest-community/jest-extended@v3.0.1...v3.0.2 ### [`v3.0.1`](https://togithub.com/jest-community/jest-extended/releases/tag/v3.0.1) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v3.0.0...v3.0.1) #### What's Changed - fix: use `readonly` array types in matchers by [@​ilyub](https://togithub.com/ilyub) in [https://github.com/jest-community/jest-extended/pull/465](https://togithub.com/jest-community/jest-extended/pull/465) - fix(types): optional `failIfNoSecondInvocation` parameter by [@​j-waaang](https://togithub.com/j-waaang) in [https://github.com/jest-community/jest-extended/pull/468](https://togithub.com/jest-community/jest-extended/pull/468) #### New Contributors - [@​ilyub](https://togithub.com/ilyub) made their first contribution in [https://github.com/jest-community/jest-extended/pull/465](https://togithub.com/jest-community/jest-extended/pull/465) - [@​j-waaang](https://togithub.com/j-waaang) made their first contribution in [https://github.com/jest-community/jest-extended/pull/468](https://togithub.com/jest-community/jest-extended/pull/468) **Full Changelog**: jest-community/jest-extended@v3.0.0...v3.0.1 ### [`v3.0.0`](https://togithub.com/jest-community/jest-extended/releases/tag/v3.0.0) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v2.1.0...v3.0.0) This is the same as https://github.com/jest-community/jest-extended/releases/tag/v2.1.0, but properly released as a major ### [`v2.1.0`](https://togithub.com/jest-community/jest-extended/releases/tag/v2.1.0) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v2.0.0...v2.1.0)⚠️ This should have been released as a major as it dropped Node 12 and 17⚠️ #### What's Changed - Restructure project by [@​mattphillips](https://togithub.com/mattphillips) in [https://github.com/jest-community/jest-extended/pull/410](https://togithub.com/jest-community/jest-extended/pull/410) - Fix broken link in example by [@​mattalexx](https://togithub.com/mattalexx) in [https://github.com/jest-community/jest-extended/pull/422](https://togithub.com/jest-community/jest-extended/pull/422) - Update toHaveBeenCalledAfter to fail if second mock is never called by [@​theryansmee](https://togithub.com/theryansmee) in [https://github.com/jest-community/jest-extended/pull/420](https://togithub.com/jest-community/jest-extended/pull/420) - Remove unsupported Node versions by [@​keeganwitt](https://togithub.com/keeganwitt) in [https://github.com/jest-community/jest-extended/pull/450](https://togithub.com/jest-community/jest-extended/pull/450) - chore(deps): lock file maintenance by [@​renovate](https://togithub.com/renovate) in [https://github.com/jest-community/jest-extended/pull/453](https://togithub.com/jest-community/jest-extended/pull/453) - chore(deps): lock file maintenance by [@​renovate](https://togithub.com/renovate) in [https://github.com/jest-community/jest-extended/pull/454](https://togithub.com/jest-community/jest-extended/pull/454) - Fix typos in matcherName in matcherHints by [@​keeganwitt](https://togithub.com/keeganwitt) in [https://github.com/jest-community/jest-extended/pull/457](https://togithub.com/jest-community/jest-extended/pull/457) - feat: upgrade to jest v28 by [@​G-Rath](https://togithub.com/G-Rath) in [https://github.com/jest-community/jest-extended/pull/463](https://togithub.com/jest-community/jest-extended/pull/463) #### New Contributors - [@​mattalexx](https://togithub.com/mattalexx) made their first contribution in [https://github.com/jest-community/jest-extended/pull/422](https://togithub.com/jest-community/jest-extended/pull/422) - [@​theryansmee](https://togithub.com/theryansmee) made their first contribution in [https://github.com/jest-community/jest-extended/pull/420](https://togithub.com/jest-community/jest-extended/pull/420) - [@​G-Rath](https://togithub.com/G-Rath) made their first contribution in [https://github.com/jest-community/jest-extended/pull/463](https://togithub.com/jest-community/jest-extended/pull/463) **Full Changelog**: jest-community/jest-extended@v2.0.0...v2.1.0 ### [`v2.0.0`](https://togithub.com/jest-community/jest-extended/releases/tag/v2.0.0) [Compare Source](https://togithub.com/jest-community/jest-extended/compare/v1.2.1...v2.0.0) #### What's Changed - feat: delete expect and jest-matcher-utils dependencies by [@​keeganwitt](https://togithub.com/keeganwitt) in [https://github.com/jest-community/jest-extended/pull/405](https://togithub.com/jest-community/jest-extended/pull/405) #### Breaking changes - Only `[email protected]` and newer is supported **Full Changelog**: jest-community/jest-extended@v1.2.1...v2.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/X-oss-byte/Nextjs).
What
predicate
contents into matcher filepredicate
tests in favour of matcher teststest/matchers/[matcher].js
src/matchers/[matcher]/index.js
tosrc/matchers/[matcher].js
this.utils
around.Why
This will simplify the codebase and we be closer to Typescript structured projects as I'd like to migrate to TS once this change is in.
Notes
Housekeeping